to the shell to return nonzero when we crap out with an error.
* Add wfClone() wrapper since we're still using PHP 4 on some servers.
* Fixed installer bugs 921 and 3914 (issues with using root and so forth)
* Remove obsolete killthread.php
+* Added wfDie() wrapper, and some manual die(-1), to force the return code
+ to the shell to return nonzero when we crap out with an error.
=== Caveats ===
define( 'MEDIAWIKI', true );
if ( isset( $_REQUEST['GLOBALS'] ) ) {
- die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+ die( -1 );
}
require_once( 'includes/Defines.php' );
return $str;
}
function _doinsert($table, $vals) {
- die( 'abstract function SqlBagOStuff::_doinsert() must be defined' );
+ wfDie( 'abstract function SqlBagOStuff::_doinsert() must be defined' );
}
function _doquery($sql) {
- die( 'abstract function SqlBagOStuff::_doquery() must be defined' );
+ wfDie( 'abstract function SqlBagOStuff::_doquery() must be defined' );
}
function _fetchrow($res) {
- die( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
+ wfDie( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
}
function _freeresult($result) {
}
function _maxdatetime() {
- die( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
+ wfDie( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
}
function _fromunixtime() {
- die( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
+ wfDie( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
}
function garbageCollect() {
/* This is actually a hack, we should be able
to use Language classes here... or not */
if (!$dbw)
- die("Could not connect to database");
+ wfDie("Could not connect to database");
$this->table = $dbw->tableName( $this->table );
$this->tableInitialised = true;
}
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
global $wgCategoryMagicGallery;
if( $wgCategoryMagicGallery )
*/
-if( !defined( 'MEDIAWIKI' ) ) die();
+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
class Categoryfinder {
# Otherwise we get a suppressed fatal error, which is very hard to track down
if ( !function_exists( 'mysql_connect' ) ) {
- die( "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
+ wfDie( "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
}
$this->close();
*/
function open( $server, $user, $password, $dbName ) {
if ( !function_exists( 'oci_connect' ) ) {
- die( "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n" );
+ wfDie( "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n" );
}
$this->close();
$this->mServer = $server;
function open( $server, $user, $password, $dbName ) {
# Test for PostgreSQL support, to avoid suppressed fatal error
if ( !function_exists( 'pg_connect' ) ) {
- die( "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" );
+ wfDie( "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" );
}
global $wgDBschema;
# This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
if( !defined( 'MEDIAWIKI' ) ) {
- die( "This file is part of MediaWiki and is not a valid entry point\n" );
+ echo "This file is part of MediaWiki and is not a valid entry point\n";
+ die( -1 );
}
/**
<?php
-if ( !defined( 'MEDIAWIKI' ) ) die();
+if ( !defined( 'MEDIAWIKI' ) ) die( -1 );
/**
* @package MediaWiki
* @subpackage Metadata
$ns = intval( $key );
$this->namespaces[$ns] = true;
} else {
- die( "Unrecognized namespace key '$key'\n" );
+ wfDie( "Unrecognized namespace key '$key'\n" );
}
}
}
wfAbruptExit( true );
}
+/**
+ * Print a simple message and die, returning nonzero to the shell if any.
+ * Plain die() fails to return nonzero to the shell if you pass a string.
+ * @param string $msg
+ */
+function wfDie( $msg='' ) {
+ echo $msg;
+ die( -1 );
+}
+
/**
* Die with a backtrace
* This is meant as a debugging aid to track down where bad data comes from.
return $string;
}
+
?>
function ConcatenatedGzipHistoryBlob() {
if ( !function_exists( 'gzdeflate' ) ) {
- die( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
+ wfDie( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
}
}
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* Hooks.php -- a tool for running hook functions
* Copyright 2004, 2005 Evan Prodromou <evan@wikitravel.org>.
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* @package MediaWiki
*
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
require_once( 'Image.php' );
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* Provide things related to namespaces
* @package MediaWiki
*/
/** */
-if (!defined('MEDIAWIKI')) die( "Not a valid entry point\n");
+if (!defined('MEDIAWIKI')) {
+ echo "Not a valid entry point\n";
+ die( -1 );
+}
/**
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* @package MediaWiki
*/
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* Sometimes one wants to make an extension that defines a class that one wants
* to backreference somewhere else in the code, doing something like:
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* Functions for dealing with proxies
* @package MediaWiki
// Check to see if we are at the file scope
if ( !isset( $wgVersion ) ) {
- die( "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n" );
+ echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
+ die( -1 );
}
if( !isset( $wgProfiling ) )
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
*
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* Entry point that create the "Preferences" object
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* PHP <4.2.0 doesn't build ctype_ functions by default and Gentoo doesn't
* build it by default, and that probably applies for some other distributions
chr($codepoint >> 6 & 0x3f | 0x80) .
chr($codepoint & 0x3f | 0x80);
- die("Asked for code outside of range ($codepoint)\n");
+ echo "Asked for code outside of range ($codepoint)\n";
+ die( -1 );
}
/**
*/
if( php_sapi_name() != 'cli' ) {
- die('');
+ die( -1 );
}
/**
* @package MediaWiki
* @subpackage Templates
*/
-if( !defined( 'MEDIAWIKI' ) ) die();
+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
/** */
require_once( 'includes/SkinTemplate.php' );
* @package MediaWiki
* @subpackage Templates
*/
-if( !defined( 'MEDIAWIKI' ) ) die();
+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
/** */
require_once( 'includes/SkinTemplate.php' );
if( !function_exists( 'version_compare' ) ) {
# version_compare was introduced in 4.1.0
- die( "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is required. ABORTING.\n" );
+ echo "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is required. ABORTING.\n";
+ die( -1 );
}
if( version_compare( phpversion(), '4.3.2' ) < 0 ) {
- die( "PHP 4.3.2 or higher is required. ABORTING.\n" );
+ echo "PHP 4.3.2 or higher is required. ABORTING.\n";
+ die( -1 );
}
if (!extension_loaded('mysql')) {
*/
function loadDefaultTables() {
$name = get_class($this);
- die("Must implement loadDefaultTables() method in class $name");
+ wfDie("Must implement loadDefaultTables() method in class $name");
}
/**
foreach ($variants as $v) {
$langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) );
if( !class_exists($langclass) ) {
- die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?");
+ wfDie( "class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?" );
}
$lang = new $langclass;
require_once( "rebuildInterwiki.inc" );
require_once( "languages/Names.php" );
if ( count( $args ) != 3 ) {
- die( "Usage: php addwiki.php <language> <site> <dbname>\n" );
+ wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
}
addWiki( $args[0], $args[1], $args[2] );
$tempname = tempnam( '/tmp', 'addwiki' );
$file = fopen( $tempname, 'w' );
if ( !$file ) {
- die( "Error, unable to open temporary file $tempname\n" );
+ wfDie( "Error, unable to open temporary file $tempname\n" );
}
fwrite( $file, $sql );
fclose( $file );
$sinks[] = $sink;
}
if( !isset( $this->outputTypes[$val] ) ) {
- die( "Unrecognized output sink type '$val'\n" );
+ wfDie( "Unrecognized output sink type '$val'\n" );
}
$type = $this->outputTypes[$val];
$sink = new $type( $param );
$sink = new DumpOutput();
}
if( !isset( $this->filterTypes[$val] ) ) {
- die( "Unrecognized filter type '$val'\n" );
+ wfDie( "Unrecognized filter type '$val'\n" );
}
$type = $this->filterTypes[$val];
$filter = new $type( $sink, $param );
}
if( !$wgUseSquid ) {
- die( "Squid purge benchmark doesn't do much without squid support on.\n" );
+ wfDie( "Squid purge benchmark doesn't do much without squid support on.\n" );
} else {
printf( "There are %d defined squid servers:\n", count( $wgSquidServers ) );
#echo implode( "\n", $wgSquidServers ) . "\n";
require_once 'commandLine.inc';
if( in_array( '--help', $argv ) )
- die(
+ wfDie(
"Usage: php changePassword.php [--user=user --password=password | --help]\n" .
"\toptions:\n" .
"\t\t--help\tshow this message\n" .
$title = $verified;
}
if( is_null( $title ) ) {
- die( "Something awry; empty title.\n" );
+ wfDie( "Something awry; empty title.\n" );
}
$ns = $title->getNamespace();
$dest = $title->getDbKey();
if ( in_array( $option, $optionsWithArgs ) ) {
$param = next( $argv );
if ( $param === false ) {
- die( "$arg needs an value after it\n" );
+ echo "$arg needs an value after it\n";
+ die( -1 );
}
$options[$option] = $param;
} else {
if ( in_array( $option, $optionsWithArgs ) ) {
$param = next( $argv );
if ( $param === false ) {
- die( "$arg needs an value after it\n" );
+ echo "$arg needs an value after it\n";
+ die( -1 );
}
$options[$option] = $param;
} else {
require_once( 'parserTests.inc' );
require_once( 'commandLine.inc' );
-if( isset($options['help']) ) { usage(); die(); }
+if( isset($options['help']) ) { usage(); wfDie(); }
$wgLanguageCode = ucfirstlcrest($wgLanguageCode);
/** Language messages we will use as reference. By default 'en' */
print "Including $langFile\n";
global $wgNamespaceNamesEn;
include($langFile);
- } else die("ERROR: The file $langFile does not exist !\n");
+ } else wfDie("ERROR: The file $langFile does not exist !\n");
}
return $$foo;
}
$testLanguage = $lang;
} else {
usage();
- die();
+ wfDie();
}
/** parsertest is used to do differences */
}
if ( in_array( '--help', $argv ) )
- die(
+ wfDie(
"Usage: php generateSitemap.php [host] [options]\n" .
"\thost = hostname\n" .
"\toptions:\n" .
}
if( wfReadOnly() ) {
- die( "Wiki is in read-only mode; you'll need to disable it for import to work.\n" );
+ wfDie( "Wiki is in read-only mode; you'll need to disable it for import to work.\n" );
}
$reader = new BackupReader();
*/
if( php_sapi_name() != 'cli' ) {
- die( "Please customize the settings and run me from the command line." );
+ echo "Please customize the settings and run me from the command line.";
+ die( -1 );
}
/** Set these correctly! */
$fname = $wgRootDirectory . "/page/" . useModFilename( $title ) . ".db";
if( !file_exists( $fname ) ) {
- die( "Couldn't open file '$fname' for page '$title'.\n" );
+ echo "Couldn't open file '$fname' for page '$title'.\n";
+ die( -1 );
}
$page = splitHash( $FS1, file_get_contents( $fname ) );
define('LOCALE_OUTPUT_DIR', $IP.'/locale');
-if( isset($options['help']) ) { usage(); die(); }
+if( isset($options['help']) ) { usage(); wfDie(); }
// default output is WikiText
if( !isset($options['lang']) ) { $options['lang'] = ALL_LANGUAGES; }
$langtool = new languages();
if ( ! function_exists( 'memory_get_usage' ) )
- die( "You must compile PHP with --enable-memory-limit\n" );
+ wfDie( "You must compile PHP with --enable-memory-limit\n" );
$memlast = $memstart = memory_get_usage();
#
if( php_sapi_name() != 'cli' ) {
- die( "Run me from the command line." );
+ echo "Run me from the command line.";
+ die( -1 );
}
/** Phpdoc script with full path */
function runTestsFromFile( $filename ) {
$infile = fopen( $filename, 'rt' );
if( !$infile ) {
- die( "Couldn't open parserTests.txt\n" );
+ wfDie( "Couldn't open parserTests.txt\n" );
}
$data = array();
$section = strtolower( $matches[1] );
if( $section == 'endarticle') {
if( !isset( $data['text'] ) ) {
- die( "'endarticle' without 'text' at line $n\n" );
+ wfDie( "'endarticle' without 'text' at line $n\n" );
}
if( !isset( $data['article'] ) ) {
- die( "'endarticle' without 'article' at line $n\n" );
+ wfDie( "'endarticle' without 'article' at line $n\n" );
}
$this->addArticle($this->chomp($data['article']), $this->chomp($data['text']), $n);
$data = array();
}
if( $section == 'end' ) {
if( !isset( $data['test'] ) ) {
- die( "'end' without 'test' at line $n\n" );
+ wfDie( "'end' without 'test' at line $n\n" );
}
if( !isset( $data['input'] ) ) {
- die( "'end' without 'input' at line $n\n" );
+ wfDie( "'end' without 'input' at line $n\n" );
}
if( !isset( $data['result'] ) ) {
- die( "'end' without 'result' at line $n\n" );
+ wfDie( "'end' without 'result' at line $n\n" );
}
if( !isset( $data['options'] ) ) {
$data['options'] = '';
continue;
}
if ( isset ($data[$section] ) ) {
- die ( "duplicate section '$section' at line $n\n" );
+ wfDie( "duplicate section '$section' at line $n\n" );
}
$data[$section] = '';
continue;
print $this->termReset() . "\n";
return ($success == $total);
} else {
- die( "No tests found.\n" );
+ wfDie( "No tests found.\n" );
}
}
. $wgDBprefix . $tbl .'`', $create);
if ($create === $create_tmp) {
# Couldn't do replacement
- die("could not create temporary table $tbl");
+ wfDie("could not create temporary table $tbl");
}
$db->query($create_tmp);
}
$this->setupGlobals();
$title = Title::newFromText( $name );
if ( is_null($title) ) {
- die( "invalid title at line $line\n" );
+ wfDie( "invalid title at line $line\n" );
}
$aid = $title->getArticleID( GAID_FOR_UPDATE );
if ($aid != 0) {
- die( "duplicate article at line $line\n" );
+ wfDie( "duplicate article at line $line\n" );
}
$art = new Article($title);
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* A basic extension that's used by the parser tests to test whether input and
* arguments are passed to extensions properly.
<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* A basic extension that's used by the parser tests to test date magic words
*
$lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
if ( !$lines || count( $lines ) < 2 ) {
- die( "m:Interwiki_map not found" );
+ wfDie( "m:Interwiki_map not found" );
}
$iwArray = array();
# Check parameters
if( @$options['help'] ) {
echo( "USAGE: removeUnusedAccounts.php [--help|--delete]\n\nThe first (default) account is ignored.\n\n" );
- die();
+ wfDie();
} else {
$delete = @$options['delete'] ? true : false ;
}
if( !function_exists( "gzdeflate" ) ) {
print "You must enable zlib support in PHP to compress old revisions!\n";
print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
- die();
+ wfDie();
}
$defaults = array(
require_once('commandLine.inc');
require_once('languages.inc');
-if( isset($options['help']) ) { usage(); die(); }
+if( isset($options['help']) ) { usage(); wfDie(); }
// default output is WikiText
if( !isset($options['output']) ) { $options['output']='wiki'; }
case 'wiki':
$out = new wikiStatsOutput(); break;
default:
- usage(); die();
+ usage(); wfDie();
break;
}
print " --help : this help message\n";
print " --list : list special pages names\n";
print " --only=page : only update 'page'. Ex: --only=BrokenRedirects\n";
- die();
+ wfDie();
}
$wgOut->disable();
define("MEDIAWIKI", 1);
if ( isset( $_REQUEST['GLOBALS'] ) ) {
print $GLOBALS;
- die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+ die( -1 );
}
require_once("./includes/Defines.php");
require_once("./LocalSettings.php");
require_once("./AdminSettings.php");
-if (!$wgEnableProfileInfo)
- die("disabled");
+if (!$wgEnableProfileInfo) {
+ wfDie("disabled");
+}
foreach (array("wgDBadminuser", "wgDBadminpassword", "wgDBserver", "wgDBname") as $var)
if ($$var === false)
- die("AdminSettings.php not correct");
+ wfDie("AdminSettings.php not correct");
$expand = array();
if (isset($_REQUEST['expand']))
$sort = $_REQUEST['sort'];
$dbh = mysql_connect($wgDBserver, $wgDBadminuser, $wgDBadminpassword)
- or die("mysql server failed: " . mysql_error());
-mysql_select_db($wgDBname, $dbh) or die(mysql_error($dbh));
+ or wfDie("mysql server failed: " . mysql_error());
+mysql_select_db($wgDBname, $dbh) or wfDie(mysql_error($dbh));
$res = mysql_query("
SELECT pf_count, pf_time, pf_name
FROM profiling
ORDER BY pf_name ASC
-", $dbh) or die("query failed: " . mysql_error());
+", $dbh) or wfDie("query failed: " . mysql_error());
if (isset($_REQUEST['filter']))
$filter = $_REQUEST['filter'];
$wgCommandLineMode = false;
define( 'MEDIAWIKI', true );
if ( isset( $_REQUEST['GLOBALS'] ) ) {
- die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+ die( -1 );
}
require_once( './includes/Defines.php' );
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('MonoBook.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* @todo document
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('includes/SkinTemplate.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('MonoBook.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* @todo document
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('MonoBook.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/**
* @todo document
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** Skin reuse monobook template */
require_once('MonoBook.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('includes/SkinPHPTal.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once( 'includes/SkinTemplate.php' );
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
require_once('includes/SkinPHPTal.php');
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
/** */
<?php
if( php_sapi_name() != 'cli' ) {
- die( 'Must be run from the command line.' );
+ echo 'Must be run from the command line.';
+ die( -1 );
}
error_reporting( E_ALL );
. $wgDBprefix . '\\1`', $create);
if ($create === $create_tmp) {
# Couldn't do replacement
- die("could not create temporary table $tbl");
+ wfDie( "could not create temporary table $tbl" );
}
$db->query($create_tmp);
}
define( 'MEDIAWIKI', true );
unset( $IP );
if ( isset( $_REQUEST['GLOBALS'] ) ) {
- die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+ die( -1 );
}
$wgNoOutputBuffer = true;
unset($IP);
define('MEDIAWIKI', true);
if ( isset( $_REQUEST['GLOBALS'] ) ) {
- die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+ die( -1 );
}
require_once('./includes/Defines.php');